package com.xuecheng.search.controller;

import com.google.j2objc.annotations.AutoreleasePool;
import com.xuecheng.commons.model.dto.CoursePubIndexDto;
import com.xuecheng.commons.model.dto.PageRequest;
import com.xuecheng.commons.model.vo.CoursePubIndexVo;
import com.xuecheng.commons.model.vo.ResponseResult;
import com.xuecheng.search.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@RestController
public class SearchController {

    @Autowired
    private SearchService searchService;

    // 分页条件查询
    @PostMapping("/course-search")
    public ResponseResult<CoursePubIndexVo> search(PageRequest pageRequest, @RequestBody CoursePubIndexDto dto) throws IOException {
        return searchService.search(pageRequest, dto);
    }

    // 根据id查询课程(免费、收费)
    @GetMapping("/course-search/{id}")
    public ResponseResult<CoursePubIndexVo> findById(@PathVariable("id")String id) throws IOException{
        return searchService.findById(id);
    }
}
